package es.deusto.ingenieria.aike.puzzle;

public class Car 
{
	public static enum Direction {
		UP,
		RIGHT,
		DOWN,
		LEFT;
	}
	
	private int y;
	private int x;
	private Direction direction;
	
	public Car (Direction direction, int x, int y)
	{		
		this.setDirection(direction);
		this.x = x;
		this.y = y;
	}
	
	public void setDirection(Direction dir)
	{
		this.direction = dir;
	}
	
	public Direction getDirection()
	{
		return this.direction;
	}
	
	public void setY(int y)
	{
		this.y = y;
	}
	
	public int getY()
	{
		return this.y;
	}
	
	public void setX(int x)
	{
		this.x = x;
	}
	
	public int getX()
	{
		return this.x;
	}
	
	public Car clone() 
	{
		return new Car(this.getDirection(), this.getY(), this.getX());
	}
	
	public boolean equals(Object obj) {
		boolean result = false;
		if (obj != null	&& obj instanceof Car) 
		{
			Car carTemp = (Car)obj;
			if (carTemp.getY() == this.getY() && 
					carTemp.getX() == this.getX() &&
						carTemp.getDirection() == this.getDirection())
				result = true;
		} 
		return result;
	}
	
	public String toString()
	{
		return "Car [row=" + y + ", col=" + x + ", direction=" + direction.name() + "]";
	}
}